//
//  UUID.m
//  Init
//
//  Created by zhaoshijie on 2018/7/20.
//  Copyright © 2018 zhaoshijie. All rights reserved.
//

#import "UUIDOnly.h"
#import"KeyChainStore.h"



@implementation UUIDOnly


+ (NSString *) getUUIDOnly
{
    
    NSString*strUUID = (NSString*)[KeyChainStore load:@"UUID_Only"];

    //首次执行该方法时，uuid为空
    if([strUUID isEqualToString:@""]|| !strUUID)
        
    {
        //生成一个uuid的方法
        
        CFUUIDRef uuidRef= CFUUIDCreate(kCFAllocatorDefault);

        strUUID = (NSString*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault,uuidRef));
        
        CFRelease(uuidRef);

        //将该uuid保存到keychain
        
        [KeyChainStore save:@"UUID_Only" data:strUUID];

    }
    
    return strUUID;
    
}

@end
